package com.Maykk.Demo01;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

/**
 * @ClassName: Demo06
 * @Description: TODO 通过反射抑制泛型检查
 * @Author: MaykkStar@163.com
 */
public class Demo06 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        ArrayList<Integer> list = new ArrayList<>();
        list.add(9527);
        // list.add("Maykk");
        // list.add(3.14f);
        // list.add(345d);
        // list.add(true);
        // list.add(12345l);
        Class<? extends ArrayList> classC = list.getClass();
        Method add = classC.getMethod("add", Object.class);
        add.invoke(list,"Maykk");
        add.invoke(list,3.14f);
        add.invoke(list,345d);
        add.invoke(list,true);
        add.invoke(list,12345l);

        System.out.println(list);

    }
}
